{% extends "layout/home_base.html" %}
{% block home_content %}
<div class="section">
  <div class="section__header">
    <h1 class="section__title">{{ _('My Domains') }}</h1>
    <div class="section__tools">
    {% if handler.user.hasPriv(model.builtin.PRIV.PRIV_CREATE_DOMAIN) %}
      <a class="primary rounded button" href="{{ url('home_domain_create') }}"><span class="icon icon-add"></span> {{ _('Create Domain') }}</a>
    {% endif %}
      <a class="tool-button" href="{{ url('wiki_help', anchor='domain') }}"><span class="icon icon-help"></span> {{ _("What's domain?") }}</a>
    </div>
  </div>
  <div class="section__body no-padding">
    <table class="data-table">
      <colgroup>
        <col class="col--icon">
        <col class="col--name">
        <col class="col--role">
        <col class="col--action">
      </colgroup>
      <thead>
        <tr>
          <th class="col--icon">&nbsp;</th>
          <th class="col--name">{{ _('Name') }} ({{ _('ID') }})</th>
          <th class="col--role">{{ _('My Role') }}</th>
          <th class="col--action">{{ _('Action') }}</th>
        </tr>
      </thead>
      <tbody>
      {%- for ddoc in ddocs -%}
        <tr>
          <td class="col--icon">
            <img src="{{ avatarUrl(ddoc.avatar, 32) }}" width="32" height="32">
          </td>
          <td class="col--name">
            <form class="form--inline" method="post">
              <input type="hidden" name="id" value="{{ ddoc['_id'] }}">
              {% set _show = handler.user.pinnedDomains.includes(ddoc._id) %}
              <input type="hidden" name="operation" value="{{ "unstar" if _show else "star" }}">
              <button class="star{% if _show %} activated{% endif %}" type="submit">
                <span class="starred--hide"><span class="icon icon-star--outline" data-tooltip="{{ _('Star') }}"></span></span>
                <span class="starred--show"><span class="icon icon-star" data-tooltip="{{ _('Unstar') }}"></span></span>
              </button>
            </form>
            {{ ddoc['name'] }} ({{ ddoc['_id'] }})
          </td>
          <td class="col--role">
            {{ dudict[ddoc._id].role|default('default') }}
          </td>
          <td class="col--action">
            <a class="typo-a" href="{{ url('homepage', domainId=ddoc['_id']) }}">{{ _('Visit') }}</a>
          {% if canManage[ddoc['_id']] %}
            · <a class="typo-a" href="{{ url('domain_dashboard', domainId=ddoc['_id']) }}">{{ _('Manage') }}</a>
          {% endif %}
          </td>
        </tr>
      {%- endfor -%}
      </tbody>
    </table>
  </div>
</div>
{% endblock %}